//
//  UIImage+Lyrics.m
//  singForYou
//
//  Created by nicolas on 2017/3/7.
//  Copyright © 2017年 nicolas. All rights reserved.
//

#import "UIImage+Lyrics.h"

@implementation UIImage (Lyrics)

- (UIImage *)imageWithLyrics:(NSString *)lyrics {
    
        CGFloat wh = MIN(self.size.width, self.size.height);
        UIGraphicsBeginImageContext(CGSizeMake(wh, wh));
        [self drawInRect:CGRectMake(0, 0, wh, wh)];
        
        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
        style.alignment = NSTextAlignmentCenter;
        NSDictionary *dict = @{
                               NSParagraphStyleAttributeName:style,
                               NSForegroundColorAttributeName:[UIColor blueColor],
                               NSFontAttributeName:[UIFont systemFontOfSize:20]
                               };
        [lyrics drawInRect:CGRectMake(0, wh-80, wh, 60) withAttributes:dict];
        UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        
        return newImage;
}
@end
